<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="../assets/js/vue.js"></script>
	</head>
	<body>
		<div id="app">
			<component v-bind:is="who"></component>
			<button @click="changeComponent">component</button>
		</div>
		<script>
			var componentA = {
				template:'<div style="color:red;">我是componentA</div>'
			}
			var componentB = {
				template:'<div style="color:green;">我是componentB</div>'
			}
			var componentC = {
				template:'<div style="color:blue;">我是componentC</div>'
			}
			var app = new Vue({
				el:"#app",
				data:{
					who:"componentA",
				},
				components:{
					"componentA":componentA,
					"componentB":componentB,
					"componentC":componentC,
				},
				methods:{
					changeComponent:function(){
						if(this.who=="componentA"){
							this.who="componentB";
						}else if(this.who=="componentB"){
							this.who = "componentC";
						}else {
							this.who = "componentA"
						}
					}
				}
				
			})
		</script>
	</body>
</html>
